<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/jsp/common/common.jsp" %>
<%
	String domainId = request.getAttribute("domainId") == null?"":request.getAttribute("domainId").toString();
	String groupId = request.getAttribute("groupId") == null?"":request.getAttribute("groupId").toString();
%>
</head>
<body>

<div class="tableMainWarp">
  <div>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="search-table">
      <tr>
      	<td width="10%">姓名：</td>
      	<td width="15%"><input class="table-input" id="employeeName" name="employeeName" value=""/></td>
      	<td width="10%">员工编号：</td>
      	<td width="15%"><input class="table-input" id="serialNumber" name="serialNumber" value=""/></td>
      	<td width="10%">账户名称：</td>
      	<td width="15%"><input class="table-input" id="accountName" name="accountName" value=""/></td>
      	<td width="10%"></td>
      	<td width="15%">
      		<button class="btn-table" id="searchButton">查询</button>
      	</td>
      </tr>	
    </table>
  </div>
  <div class="tablelist">
    <div class="tabcon" id="middleCon"  style="overflow: auto;"></div>
    <div id="paginationDiv"  class="page clearfix"></div>
  </div>
</div>

<script type="text/javascript">

$(document).ready(function(){
	
	var bodyHt=document.documentElement.clientHeight;
	var tableDivHeight = bodyHt-97;	
	$('#middleCon').height(tableDivHeight);
	
	getPageData();

	initTable();
	
	blindPageElement();
	
});

function blindPageElement(){

	//绑定查询按钮
	$('#searchButton').on('click',function(){
		$('#middleCon').tablegrid('reload',{
			domainId : '<%=domainId%>',
			employeeName : $('#employeeName').val(),
			serialNumber : $('#serialNumber').val(),
			accountName : $('#accountName').val()
		});
	});
	
}

function initTable(){
 	
	var url = "<%=basePath%>/biz/ou/employee/getEmployeeIdentityListData.do?domainId=<%=domainId %>";
	tablegridGobalObject = $('#middleCon').tablegrid({
		url: url,
		columns:[	
		         	{field:'id',ischeckbox:true,align:'center',width:4},
		   	        {field:'empName',title:'姓名',width:11},
		   	        {field:'empSerialNumber',title:'员工编号',width:11},
		   	     	{field:'accountName',title:'登陆账户名称',width:13},
		   	     	{field:'positionName',title:'职务名称',width:11},
		   	     	{field:'positionLevel',title:'职务级别',width:11},
		   	        {field:'orgName',title:'部门名称',width:15},
		   	        {field:'orgSerialNumber',title:'部门编号',width:11},
		   	     	{field:'orgLevelName',title:'部门级别',width:13}
			    ],
	    isPagination: true,
	    resizeColumns: true,
	    isFristData: true,
	    pageConifg: {
	    	pageId : 'paginationDiv'
	    },
	    tableClass : 'table-form'
	});
}


function getPageData(){
}

function userNameFormatterFunction(value, rowdata, index){
	
	var aObj = $('<a href="javascript:;"></a>').on('click',function(){
		showAlert('正在建设中');
	}).append(value);
	
	return aObj;
}

function stateFormatterFunction(value, rowdata, index){
	if(value && value != ''){
		
		if(value == 'A'){
			return '启用';
		}else if(value == 'F'){
			return '禁用';
		}else{
			return '未知';
		}
		
	}else{
		return '';
	}
}


function onConfrim(layerObject,tablegridGobalObject){
	
	var url = '<%=basePath%>/biz/ou/group/addEIToGroup.do?domainId=<%=domainId %>';
	url = url + '&groupId=<%=groupId%>';
	var rowdataArray = $('#middleCon').tablegrid('getSelect');
	var jsonData = new Array();
	
	$(rowdataArray).each(function(index,entry){
		jsonData.push(entry.eiId);
	});
	
	var jsonDataStr = JSON.stringify(jsonData);
	$.ajax({
		url : url,
		type : 'post',
		dataType : 'json',
		data:{jsonData:jsonDataStr},
		success : function(data, textStatus, jqXHR) {
			showAlert('添加成功',function(){
				layerObject.close();
				tablegridGobalObject.reload();
			});
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
		}
	});
	
}


</script>
</body>
</html>